import React, { useEffect, useState } from 'react'

const App = () => {
	const [count, setCount] = useState(0)

	// 会在组件挂载完成之后执行  组件数据更新完成之后执行
	useEffect(() => {
		console.log('123')
	})

	// 只在组件挂载完成执行
	useEffect(() => {
		console.log('456')
	}, [])

	// 组件卸载之前执行
	useEffect(() => {
		return () => {
			console.log('789')
		}
	})
	return (
		<div>
			<span>{count}</span>
			<button
				onClick={() => {
					setCount(count + 1)
				}}
			>
				+1
			</button>
		</div>
	)
}
